package com.vayne.sourcedemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.annotation.PostConstruct;

/**
 * @author xuerui.zhang
 * @since 2020/4/16 下午6:18
 */
public class ResolvableDependencyDemo {

    @Autowired
    private String value;

    @PostConstruct
    private void init() {
        System.out.println(this.value);
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
        applicationContext.register(ResolvableDependencyDemo.class);

       applicationContext.addBeanFactoryPostProcessor(beanFactory ->
               beanFactory.registerResolvableDependency(String.class, "Hello ResolvableDependency"));

        applicationContext.refresh();
        applicationContext.close();
    }
}
